package com.dao;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;

/**
 * A data access object (DAO) providing persistence and search support for
 * PointJcdTb entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.dao.PointJcdTb
 * @author MyEclipse Persistence Tools
 */

public class PointJcdTbDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(PointJcdTbDAO.class);
	// property constants
	public static final String XH = "xh";
	public static final String JCD_EQUIP_ID = "jcdEquipId";
	public static final String ORG_ID = "orgId";
	public static final String JCD_MEDIA_ID = "jcdMediaId";
	public static final String JCD_NAME = "jcdName";
	public static final String JCD_XS = "jcdXs";
	public static final String JCD_SM = "jcdSm";
	public static final String JCD_MARK = "jcdMark";
	public static final String JCD_SFYX = "jcdSfyx";
	public static final String JCD_XSSX = "jcdXssx";
	public static final String JCD_DATASOURCE = "jcdDatasource";
	public static final String JCD_TYPE = "jcdType";
	public static final String JCD_ZXLC = "jcdZxlc";
	public static final String JCD_ZDLC = "jcdZdlc";
	public static final String JCD_YBZT = "jcdYbzt";
	public static final String JCD_WD = "jcdWd";
	public static final String JCD_UNIT = "jcdUnit";

	public void save(PointJcdTb transientInstance) {
		log.debug("saving PointJcdTb instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(PointJcdTb persistentInstance) {
		log.debug("deleting PointJcdTb instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public PointJcdTb findById(java.lang.Integer id) {
		log.debug("getting PointJcdTb instance with id: " + id);
		try {
			PointJcdTb instance = (PointJcdTb) getSession().get(
					"com.dao.PointJcdTb", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(PointJcdTb instance) {
		log.debug("finding PointJcdTb instance by example");
		try {
			List results = getSession().createCriteria("com.dao.PointJcdTb")
					.add(Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding PointJcdTb instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from PointJcdTb as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByXh(Object xh) {
		return findByProperty(XH, xh);
	}

	public List findByJcdEquipId(Object jcdEquipId) {
		return findByProperty(JCD_EQUIP_ID, jcdEquipId);
	}

	public List findByOrgId(Object orgId) {
		return findByProperty(ORG_ID, orgId);
	}

	public List findByJcdMediaId(Object jcdMediaId) {
		return findByProperty(JCD_MEDIA_ID, jcdMediaId);
	}

	public List findByJcdName(Object jcdName) {
		return findByProperty(JCD_NAME, jcdName);
	}

	public List findByJcdXs(Object jcdXs) {
		return findByProperty(JCD_XS, jcdXs);
	}

	public List findByJcdSm(Object jcdSm) {
		return findByProperty(JCD_SM, jcdSm);
	}

	public List findByJcdMark(Object jcdMark) {
		return findByProperty(JCD_MARK, jcdMark);
	}

	public List findByJcdSfyx(Object jcdSfyx) {
		return findByProperty(JCD_SFYX, jcdSfyx);
	}

	public List findByJcdXssx(Object jcdXssx) {
		return findByProperty(JCD_XSSX, jcdXssx);
	}

	public List findByJcdDatasource(Object jcdDatasource) {
		return findByProperty(JCD_DATASOURCE, jcdDatasource);
	}

	public List findByJcdType(Object jcdType) {
		return findByProperty(JCD_TYPE, jcdType);
	}

	public List findByJcdZxlc(Object jcdZxlc) {
		return findByProperty(JCD_ZXLC, jcdZxlc);
	}

	public List findByJcdZdlc(Object jcdZdlc) {
		return findByProperty(JCD_ZDLC, jcdZdlc);
	}

	public List findByJcdYbzt(Object jcdYbzt) {
		return findByProperty(JCD_YBZT, jcdYbzt);
	}

	public List findByJcdWd(Object jcdWd) {
		return findByProperty(JCD_WD, jcdWd);
	}

	public List findByJcdUnit(Object jcdUnit) {
		return findByProperty(JCD_UNIT, jcdUnit);
	}

	public List findAll() {
		log.debug("finding all PointJcdTb instances");
		try {
			String queryString = "from PointJcdTb";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public PointJcdTb merge(PointJcdTb detachedInstance) {
		log.debug("merging PointJcdTb instance");
		try {
			PointJcdTb result = (PointJcdTb) getSession().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(PointJcdTb instance) {
		log.debug("attaching dirty PointJcdTb instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(PointJcdTb instance) {
		log.debug("attaching clean PointJcdTb instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}